package com.ruoyi.wxarea.controller;



import com.ruoyi.wxarea.mapper.AddressUserMapper;
import com.ruoyi.wxarea.pojo.AddressUser;
import com.ruoyi.wxarea.service.IAddressUserService;
import com.ruoyi.wxarea.service.IAreaService;
import com.ruoyi.wxcommon.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 凡哥哥
 * @since 2024-05-06
 */
@RestController
@RequestMapping("/area/user")
public class AddressUserController {
    @Resource
    AddressUserMapper addressUserMapper;
    @Autowired
    IAddressUserService addressUserService;
    @Autowired
    IAreaService areaService;
    @PostMapping("/address/get")
    public Result getAddress(Integer pageIndex, Integer pageSize, Integer wxId){
        return addressUserService.selectUserAddressById(pageIndex, pageSize, wxId);
    }
    /*@PostMapping("/get/aid")
    public Result getAreaById(Integer aid){
        Area area = areaService.getById(aid);
        return Result.SUCCESS(area);
    }*/
    @PostMapping("/address/{url}")
    public Result addAddress(@PathVariable String url, String address, String detail, Integer wxId, Integer id){

        return addressUserService.addAddress(url,address,detail,wxId,id);
    }
    @GetMapping("/userInfo")
    public Result userInfo(Integer id){
        AddressUser addressUser = addressUserMapper.QueryById(id);
        return Result.SUCCESS(addressUser);
    }



}

